//
//  ChaosLabel.m
//  meiang_edu
//
//  Created by Liubi_Chaos_G on 2018/7/30.
//  Copyright © 2018年 com.meiang.meiang_edu. All rights reserved.
//

#import "ChaosLabel.h"
#define ChaosRed (81.0/255.0)
#define ChaosGreen (81.0/255.0)
#define ChaosBlue (81.0/255.0)
#define iChaosRed (255.0/255.0)
#define iChaosGreen (255.0/255.0)
#define iChaosBlue (255.0/255.0)

@interface ChaosLabel ()

@property (weak, nonatomic) IBOutlet UILabel *textLabel;

@end

@implementation ChaosLabel

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.autoresizingMask = UIViewAutoresizingNone;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil] firstObject];
        self.textLabel.font = [UIFont systemFontOfSize:FONT_SIZE_18 weight:UIFontWeightBold];
        self.textLabel.textColor = [UIColor colorWithRed:ChaosRed green:ChaosGreen blue:ChaosBlue alpha:1.0];
        self.textLabel.textAlignment = NSTextAlignmentCenter;
        self.backgroundColor = [UIColor whiteColor];
        self.userInteractionEnabled = YES;
        self.indicatorView.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)setScale:(CGFloat)scale
{
    _scale = scale;
    
    //      R G B
    // 默认：0.4 0.6 0.7
    // 红色：1   0   0
    
    CGFloat red = ChaosRed + ((80/255.0) - ChaosRed) * scale;
    CGFloat green = ChaosGreen + ((172/255.0) - ChaosGreen) * scale;
    CGFloat blue = ChaosBlue + ((204/255.0) - ChaosBlue) * scale;
    
    CGFloat ired = iChaosRed + ((80/255.0) - iChaosRed) * scale;
    CGFloat igreen = iChaosGreen + ((172/255.0) - iChaosGreen) * scale;
    CGFloat iblue = iChaosBlue + ((204/255.0) - iChaosBlue) * scale;
//    self.countLabel.textColor = [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
//    self.nameLabel.textColor = [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
    self.textLabel.textColor = [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
    self.indicatorView.backgroundColor = [UIColor colorWithRed:ired green:igreen blue:iblue alpha:1.0];
    // 大小缩放比例
    //    CGFloat transformScale = 1 + scale * 0.15; // [1, 1.3]
    //    self.transform = CGAffineTransformMakeScale(transformScale, transformScale);
}

- (void)setText:(NSString *)text {
    _text = text;
    self.textLabel.text = text;
}

@end
